<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>添加专题</title>
<link href="${ctx }/style/css_member.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="${ctx }/js/common.js"></script>
<script src="${ctx }/js/artDialog.js?skin=gray"></script>
<script src="${ctx }/js/artDialog.iframeTools.js"></script>
<script type="text/javascript" src="${ctx }/js/jquery-1.3.2.js"></script>
<script type="text/javascript" src="${ctx }/js/ajaxupload.js"></script>
<style type="text/css">
.newItem{padding: 5px 0px 10px 0px;margin: 0 auto;width: 960px;overflow: hidden;font-size: 14px;color: #666666;}
.leftItem{float:left;width: 150px;text-align: right;}
.rightItem{float: left;padding: 0px 0px 0px 10px;}
.style15 {color: #FF6600}
.color_div{float:left;margin:0px 0px 0px 10px;width: 16px;height: 16px;cursor: pointer;}
</style>

<script type="text/javascript">

$(document).ready(function(){

	new AjaxUpload("#upload_backimage_button", {
		action : "${ctx }/advertise/specialSubjectAction!uploadImage.do",
		autoSubmit : true,
		name : "myFile",
		onSubmit : function(file, extension) {
			if (extension && /^(jpg|png|jpeg|gif)$/i.test(extension)) {
			} else {
				alert("你所选择的文件不受系统支持");
				return false;
			}
		},
		onComplete : function(file, response) {
			var jsonObj = eval('('+response+')');
			var code = jsonObj.code;
			var message = jsonObj.message;
			if( code == "0000"){
				$("#backimage_span").text(message);
				$("#back_image").val(message);
			}else{
				alert(message);
			}
		}
	});

	$("#choose_painter_button").click(function(){
		art.dialog.open('${ctx }/advertise/specialSubjectAction!queryPainters.do',{title:'选择画家',width:750,height:550},false);
    });

	m2('m1_007','m1_007_05');
});

/****检查表单 ***/
function checkForm(){

	var title1 = $.trim($("#title1").val());
	if(title1 == ""){
		$("#title1").focus();
		alert("请填写主标题。");
		return false;
	}
	var title1_color = $("#title1_color").val();
	if(title1_color == ""){
		alert("请选择主标题颜色。");
		return false;
	}

	var title2 = $.trim($("#title2").val());
	if( title2 == ""){
		$("#title2").focus();
		alert("请填写副标题。");
		return false;
	}
	var title2_color = $("#title2_color").val();
	if( title2_color == ""){
		alert("请选择副标题颜色。");
		return false;
	}

	var description1 = $.trim($("#description1").val());
	if( description1 == ""){
		$("#description1").focus();
		alert("请填写描述文字。");
		return false;
	}
	var description_color = $("#description_color").val();
	if( description_color == ""){
		alert("请选择描述文字颜色。");
		return false;
	}

	var  back_image = $("#back_image").val();
	if( back_image == ""){
		alert("请上传抬头底图。");
		return false;
	}

	var background_color = $("#background_color").val();
	if( background_color == ""){
		alert("请选择抬头底色。");
		return false;
	}

	var painterID = $("#painterID").val();
	if( painterID == "" ){
		alert("请选择画家。");
		return false;
	}

	return true;
}

/** 返回列表 **/
function backtolist(){

	location.href = "${ctx}/advertise/specialSubjectAction!list.do";
}

/**** 选择颜色 ****/
function check_color(id,color){
	$("#"+id).val(color);
	alert("已选择颜色："+color);
}

/*** 预览  ****/
function previewSpecialAdvertise(){

	if(!checkForm()){
		return false;
	}

	$("#specialsubjectForm").attr("action","${ctx }/advertise/specialSubjectAction!preview.do");
	$("#specialsubjectForm").attr("target","_blank");
	$("#specialsubjectForm").submit();
}

/*** 保存 ****/
function saveSpecialAdvertise(){
	if(!checkForm()){
		return false;
	}

	if (window.confirm("确认提交？")) {
		$("#specialsubjectForm").attr("action","${ctx }/advertise/specialSubjectAction!save.do");
		$("#specialsubjectForm").attr("target","_self");
		$("#specialsubjectForm").submit();
	}
}

</script>

</head>
<body>

<jsp:include page="/commons/head_member.jsp"></jsp:include>

<div style="width: 960px;margin: 0 auto;background: #ffffff;margin-top: 5px;padding-bottom: 30px;">
	<form action="${ctx }/advertise/specialSubjectAction!save.do" method="post" id="specialsubjectForm" name="specialsubjectForm">
		<div style="font-size: 16px;text-align: center;padding: 20px 0px;">专题设计</div>
		<div class="newItem">
			<div class="leftItem"><span class="style15">*</span>主标题：</div>
			<div class="rightItem"><input name="specialSubject.title1" id="title1" maxlength="25"/></div>
			<div class="rightItem">
				<div style="float: left;">字体颜色
					<input type="hidden" value="" name="specialSubject.title1_color" id="title1_color"/>
				</div>
				<div class="color_div" style="background:#050505" onclick="check_color('title1_color','#050505')"></div>
				<div class="color_div" style="background:#a7a7a7" onclick="check_color('title1_color','#a7a7a7')"></div>
				<div class="color_div" style="background:#d9d9d9" onclick="check_color('title1_color','#d9d9d9')"></div>
				<div style="float:left;margin:0px 0px 0px 10px;width: 14px;height: 14px;cursor: pointer;background:#ffffff;border: 1px solid #000000;" onclick="check_color('title1_color','#ffffff')"></div>
				<div class="color_div" style="background:#ff8402" onclick="check_color('title1_color','#ff8402')"></div>
				<div class="color_div" style="background:#bb7e21" onclick="check_color('title1_color','#bb7e21')"></div>
				<div class="color_div" style="background:#fe0103" onclick="check_color('title1_color','#fe0103')"></div>
				<div class="color_div" style="background:#97191a" onclick="check_color('title1_color','#97191a')"></div>
				<div class="color_div" style="background:#ff02b5" onclick="check_color('title1_color','#ff02b5')"></div>
				<div class="color_div" style="background:#8b135a" onclick="check_color('title1_color','#8b135a')"></div>
				<div class="color_div" style="background:#031afe" onclick="check_color('title1_color','#031afe')"></div>
				<div class="color_div" style="background:#03bafe" onclick="check_color('title1_color','#03bafe')"></div>
				<div class="color_div" style="background:#176d8e" onclick="check_color('title1_color','#176d8e')"></div>
				<div class="color_div" style="background:#237e07" onclick="check_color('title1_color','#237e07')"></div>
				<div class="color_div" style="background:#9b9e07" onclick="check_color('title1_color','#9b9e07')"></div>
			</div>
		</div>
		<div class="newItem">
			<div class="leftItem"><span class="style15">*</span>副标题：</div>
			<div class="rightItem"><input name="specialSubject.title2" id="title2" size="40" maxlength="50"/></div>
			<div class="rightItem">
				<div style="float: left;">字体颜色
					<input type="hidden" value="" name="specialSubject.title2_color" id="title2_color"/>
				</div>
				<div class="color_div" style="background:#050505" onclick="check_color('title2_color','#050505')"></div>
				<div class="color_div" style="background:#a7a7a7" onclick="check_color('title2_color','#a7a7a7')"></div>
				<div class="color_div" style="background:#d9d9d9" onclick="check_color('title2_color','#d9d9d9')"></div>
				<div style="float:left;margin:0px 0px 0px 10px;width: 14px;height: 14px;cursor: pointer;background:#ffffff;border: 1px solid #000000;" onclick="check_color('title2_color','#ffffff')"></div>
				<div class="color_div" style="background:#ff8402" onclick="check_color('title2_color','#ff8402')"></div>
				<div class="color_div" style="background:#bb7e21" onclick="check_color('title2_color','#bb7e21')"></div>
				<div class="color_div" style="background:#fe0103" onclick="check_color('title2_color','#fe0103')"></div>
				<div class="color_div" style="background:#97191a" onclick="check_color('title2_color','#97191a')"></div>
				<div class="color_div" style="background:#ff02b5" onclick="check_color('title2_color','#ff02b5')"></div>
				<div class="color_div" style="background:#8b135a" onclick="check_color('title2_color','#8b135a')"></div>
				<div class="color_div" style="background:#031afe" onclick="check_color('title2_color','#031afe')"></div>
				<div class="color_div" style="background:#03bafe" onclick="check_color('title2_color','#03bafe')"></div>
				<div class="color_div" style="background:#176d8e" onclick="check_color('title2_color','#176d8e')"></div>
				<div class="color_div" style="background:#237e07" onclick="check_color('title2_color','#237e07')"></div>
				<div class="color_div" style="background:#9b9e07" onclick="check_color('title2_color','#9b9e07')"></div>
			</div>
		</div>
		<div class="newItem">
			<div class="leftItem"><span class="style15">*</span>描述：</div>
		</div>
		<div class="newItem">
			<div class="leftItem">1</div>
			<div class="rightItem"><input name="specialSubject.description1" id="description1" size="60" maxlength="60"/></div>
		</div>
		<div class="newItem">
			<div class="leftItem">2</div>
			<div class="rightItem"><input name="specialSubject.description2" id="description2" size="60" maxlength="60"/></div>
		</div>
		<div class="newItem">
			<div class="leftItem">3</div>
			<div class="rightItem"><input name="specialSubject.description3" id="description3" size="60" maxlength="60"/></div>
			<div class="rightItem">
				<div style="float: left;">字体颜色
					<input type="hidden" value="" name="specialSubject.description_color" id="description_color"/>
				</div>
				<div class="color_div" style="background:#050505" onclick="check_color('description_color','#050505')"></div>
				<div class="color_div" style="background:#a7a7a7" onclick="check_color('description_color','#a7a7a7')"></div>
				<div class="color_div" style="background:#d9d9d9" onclick="check_color('description_color','#d9d9d9')"></div>
				<div style="float:left;margin:0px 0px 0px 10px;width: 14px;height: 14px;cursor: pointer;background:#ffffff;border: 1px solid #000000;" onclick="check_color('description_color','#ffffff')"></div>
			</div>
		</div>
		<div class="newItem">
			<div class="leftItem"><span class="style15">*</span>抬头底图：</div>
			<div class="rightItem"><span id="backimage_span"></span>
				<a href="#" id="upload_backimage_button">上传</a>
				<input type="hidden" name="back_image" id="back_image" value=""/>
			</div>
		</div>
		<div class="newItem">
			<div class="leftItem"><span class="style15">*</span>抬头底色：</div>
			<div class="rightItem">
				<div style="float: left;">
					<input type="hidden" value="${specialSubject.background_color }" name="specialSubject.background_color" id="background_color"/>
				</div>
				<div class="color_div" style="background:#050505" onclick="check_color('background_color','#050505')"></div>
				<div class="color_div" style="background:#a7a7a7" onclick="check_color('background_color','#a7a7a7')"></div>
				<div class="color_div" style="background:#d9d9d9" onclick="check_color('background_color','#d9d9d9')"></div>
				<div style="float:left;margin:0px 0px 0px 10px;width: 14px;height: 14px;cursor: pointer;background:#ffffff;border: 1px solid #000000;" onclick="check_color('background_color','#ffffff')"></div>
				<div class="color_div" style="background:#ff8402" onclick="check_color('background_color','#ff8402')"></div>
				<div class="color_div" style="background:#bb7e21" onclick="check_color('background_color','#bb7e21')"></div>
				<div class="color_div" style="background:#fe0103" onclick="check_color('background_color','#fe0103')"></div>
				<div class="color_div" style="background:#97191a" onclick="check_color('background_color','#97191a')"></div>
				<div class="color_div" style="background:#ff02b5" onclick="check_color('background_color','#ff02b5')"></div>
				<div class="color_div" style="background:#8b135a" onclick="check_color('background_color','#8b135a')"></div>
				<div class="color_div" style="background:#031afe" onclick="check_color('background_color','#031afe')"></div>
				<div class="color_div" style="background:#03bafe" onclick="check_color('background_color','#03bafe')"></div>
				<div class="color_div" style="background:#176d8e" onclick="check_color('background_color','#176d8e')"></div>
				<div class="color_div" style="background:#237e07" onclick="check_color('background_color','#237e07')"></div>
				<div class="color_div" style="background:#9b9e07" onclick="check_color('background_color','#9b9e07')"></div>
			</div>
		</div>
		<div class="newItem">
			<div class="leftItem"><span class="style15">*</span>定义画家：</div>
			<div class="rightItem"><span id="painter_name"></span><input type="hidden" value="" name="specialSubject.painterID" id="painterID"/>
				<a href="#" id="choose_painter_button">选择画家</a>
			</div>
		</div>
		<div class="newItem">
			<div class="leftItem">广告推荐：</div>
			<div class="rightItem">
				<input type="checkbox" name="channelIDs" value="1"/>首页
				<input type="checkbox" name="channelIDs" value="2"/>瓷艺
				<input type="checkbox" name="channelIDs" value="3"/>绘画
			</div>
		</div>
		<div class="newItem">
			<div class="leftItem">&nbsp;</div>
			<div class="rightItem">
				<span><input class="btn_2" type="button" value="预 览" onclick="previewSpecialAdvertise()"/></span>
				<span style="padding-left: 50px;"><input class="btn_2" type="button" value="保 存" onclick="saveSpecialAdvertise()"/></span>
				<span style="padding-left: 50px;"><input class="btn_6" type="button" value="返回专题列表" onclick="backtolist()"/></span>
			</div>
		</div>
	</form>
</div>

<jsp:include page="/commons/foot_member.jsp"></jsp:include>

</body>
</html>